function [Samples, Labels] = GenerateData(NumberOfClasses,...
                             NumberOfDimensions,MaxNumberOfSamples)

%//////////////////////////////////////////////////////////////////////////
%////  Generate sintetic data /////////////////////////////////////////////
%//////////////////////////////////////////////////////////////////////////


% Set a fixed seed if reproducible experiments are desired
% otherwise comment following line
%rand('seed',0);

load semilla
rng(s);
rand(10);
%rng('default');

% Inicialization
Samples = [];
Labels = [];

for clas = 1:NumberOfClasses,
    % Set for each class a random number of modes -------------------------
    MaxNumberOfModes = 10; %(Maximum number of modes allowed)
    NumberOfModes = round((MaxNumberOfModes-1)*rand(1))+1;
    % ---------------------------------------------------------------------
    
    % Set for each class a random number of samples -----------------------
    % MaxNumberOfSamples = 5000; now define as input
    NumberOfSamples = round((MaxNumberOfSamples-1)*rand(1))+1;
    % ---------------------------------------------------------------------
    
    for mode = 1:NumberOfModes,
        % Generate random samples with random mean and sigma --------------
        Mean = 5*rand(NumberOfDimensions,1);
        Sigma = rand(NumberOfDimensions,1);
        SigmaMatrix = diag(Sigma) ;
        RandomMatrix = randn(round(NumberOfSamples/NumberOfModes)+1,...
            NumberOfDimensions);
        
        NewData = RandomMatrix * SigmaMatrix + ...
                  ones(size(RandomMatrix)) * diag(Mean);
        % -----------------------------------------------------------------
        
        % Add data to the set of samples 
        Samples = [Samples; NewData];
        Labels = [Labels; clas*ones(size(NewData,1),1)];
    end
       
end
    
    